package com.ktjiaoyu.crm;

import com.ktjiaoyu.crm.pojo.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

import javax.annotation.Resource;

@SpringBootTest
public class RedisTemplateTester {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Resource
    private RedisTemplate<String, User> redisTemplate;

    @Test
    public void testStringRedisTemplate(){
        stringRedisTemplate.opsForValue().set("age","18");
        System.out.println(stringRedisTemplate.opsForValue().get("age"));

        User user = new User("test","123");
        ValueOperations<String, User> stringUserValueOperations = redisTemplate.opsForValue();
        stringUserValueOperations.set("user:user1",user);
        User user1 = stringUserValueOperations.get("user:user1");
        System.out.println(user1.getUsrName());

    }

}
